// --------------------------------------------------------------------
//   name 	: 
//   desc 	: 
//   version 	: 
//   dev 	: 
// --------------------------------------------------------------------
// DEPENDENCIES
// 
// --------------------------------------------------------------------
// CHANGE HISTORY
// 0.1 	Initial Release
// --------------------------------------------------------------------
	plugins.setAlias = { // Add an alias for a village
		'enhance_game_main' : function() {
			$("form table").clone().insertAfter("form table");
			$("form table:last th").html(twe.lang("main_setaliasheader"));

			var link = $("table.main table.vis a:first")[0];
			var tmpId = link.getAttribute("href").match( /village=([^&]+)/ );

			$("form table:last td:last input").remove();
			$("form table:last td:last").html("<a href=\"javascript:setAlias("+tmpId[1]+");\">"+twe.lang("main_setalias")+"</a>");
			$("form table:last").after("<p id=\"setaliasdone\" style=\"display: none\">"+twe.lang("main_setaliasdone")+"</p>");

			var entry = $("form table:last td:first input")[0];
			entry.setAttribute("id", "alias");
			entry.setAttribute("name", "alias");

			var tmp = new String(getValue("villageinfo_"+tmpId[1]));
			tmp = tmp.split(",");
			if (tmp[1] && tmp[1] != 'undefined') { entry.value = decodeURIComponent(tmp[1]); } else { entry.value = ''; }

			setFunc("setAlias", function(ident) {
				window.setTimeout(function() {
					var tmp = new String(getValue("villageinfo_"+ident));
					tmp = tmp.split(",");
					if (!tmp[0]) tmp[0] = 0;
					setValue("villageinfo_"+ident, ""+tmp[0]+","+encodeURIComponent($("#alias").val()));
					$("#setaliasdone").fadeIn("slow");
				}, 0);
			});
		},
  'info' : {
	  'mandatory' : false,
   'name' : "Village aliases",
   'desc' : "Aliases for villages to rename them on your local machine only for you to see",
   'version' : "0.1",
   'dev' : "Timas"
  }
	};
